﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;

namespace ECSE6770.Controllers
{
    [RequireHttps]
    [Authorize]
    public class ClientBinController : BaseController
    {
        public ActionResult V(int id)
        {
            if (ContextManager.CurrentUser.Interop.OwnsVideo(id))
            {
                var video = Db.Videos.First(v => v.Id == id);
                return new FileStreamResult(new FileStream(VideoManager.FullyQualifyFile(video.FileName), FileMode.Open), video.MimeType);
            }
            else
                throw new HttpException(403, "Forbidden");
        }

#if DEBUG
        public ActionResult Test()
        {
            return new FileStreamResult(new FileStream(@"D:\videos\wildlife.wmv", FileMode.Open), "video/x-ms-wmv");
        }
#endif
    }
}
